home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
001
/
int24.aqm
/
int24.asm
Wrap
Assembly Source File
|
1986-09-18
|
10KB
|
267 lines
;*****************************************************************************
;* THIS IS A COMMENTED VERSION OF THE MS-DOS 2.1 INT24H CRITICAL ERROR
;* HANDLER. THE ASSEMBLER WAS GENERATED BY DEBUG'S UNASSEMBLE COMMAND.
;* Marc Adler - Magma Software Systems
;*****************************************************************************
0534:04E2 INTERRUPT 24H handler (critical errors)
; Save registers and enable further interrupts
STI
PUSH DS
PUSH ES
PUSH DI
PUSH CX
PUSH AX
; BP:SI points to the device header. AH contains the device info.
; Lower half of DI contains the error type.
MOV DS,BP ; DS now references the device header
MOV AX,[SI+04] ; AX has device info - bit 15 is 1 if device
MOV CS:[080F],AH ; is a char device - 0 if it's a block device
; Transfer the device name to an area at CS:07B7
PUSH CS
POP ES
MOV DI,07B7
MOV CX,0008
ADD SI,0A
REPZ
MOVSB
; Restore the saved registers
POP AX
POP CX
POP DI
POP ES
; The following call puts the contents at PSP[18H] into [930]. Then it
; copies the contents of PSP[1AH] into PSP[18H].
; DOS seems to keep a table of file handles from 18H to 2BH (undocumented).
; The file handle at 18H is the handle for standard input, and the handle
; at 1AH is the handle for standard output. Location 930 seems to be a
; temp storage location to hold file handle 0.
CALL 04C6 ; int21(51H); [930] = [018]; [018] = [01A];
; Establish addressability for the DS register
PUSH CS ; DS = this segment
POP DS
; Output a carriage return
PUSH DX
CALL 0632 ; put_cr();
POP DX
; Poke the offending drive's letter into the error message
ADD AL,41 ; AL += 'A'
MOV [07AC],AL ; Put offending drive's letter in [07AC]
; If the error isn't a disk error, and the offending device is a block
; device, then we must have a bad FAT table.
TEST AH,80 ; if the error is not a disk error
JE 0521
TEST BYTE PTR [080F],80 ; if device is a block device
JNE 0521
JMP 05D9 ; fat_bad()
; Unreachable code (?)
MOV SI,0793 ; next 3 stmts are unreachable
TEST AH,01
JE 052C
; Poke either "read" or "writ" into the error message
0521: MOV SI,0797
LODSW
MOV [079E],AX ; [079E] = [0797] "wr"
LODSW
MOV [07A0],AX ; [07A0] = [0799] "it"
; Use the error code as an index into an array of error message pointers,
; and print the error message.
; Remember that low half of DI contains the error code
052C: AND DI,00FF ; if (DI > 12)
CMP DI,0C
JBE 0540
MOV DI,000C ; DI = 12;
0540: MOV [092E],DI ; use err code as index into a message array
SHL DI,1 ; There are 13 possible msgs, 0-12
MOV DI,[DI+06E7] ; [06E7-06FF] indexes the message
XCHG DX,DI
CALL 0635 ; print the message
MOV DX,079B ; print "reading" or "writing"
CALL 0635
TEST BYTE PTR [080F],80;if ([80F] & 0x80) /* char device */
JE 0565 ; {
MOV DX,07AF ; print "device"
MOV AH,09 ; }
INT 21
JMP 0577 ; else /* disk device */
0565: MOV DX,07A5 ; {
CALL 0635 ; print "drive <d>"
CMP BYTE PTR [0932],0; if ([0932] != 0) /* What's 932? */
JE 0577 ; {
CALL 05EF ; Restore orginal file handle 0
JMP 05E9 ; command_bad();
; }
; }
; Print the "Abort, Retry, Ignore" message, and get the user's response
0577: MOV DX,07F9 ; print 'Abort, Retry, Ignore' message
CALL 0635
057D: MOV AX,0C01 ; get user response
INT 21
CALL 0632
; Process the user's response
OR AL,20 ; convert response to lower case
MOV AH,00 ; AH holds code (0,1,2) to return to DOS
CMP AL,69 ; did user specify 'i' (ignore) ?
JE 05D0 ; YES - return to DOS
INC AH ; retry's return code is 1
CMP AL,72 ; user specified 'r' (retry) ?
JE 05D0 ; YES - return to DOS
INC AH ; abort's return code is 2
CMP AL,61 ; user specified 'a' (abort) ?
JNE 0577 ; NO - reprint msg & get response
; At this point, the user specified the 'ABORT' response
abort()
{
0599: XOR DX,DX
XCHG [0A77],DL ; DL = [0A77]; [0A77] = 0;
OR DL,DL ; if (DL != 0)
JE 05B0 ; {
CMP WORD PTR [0973],00 ; if ([0973] != 0)
JE 05B0 ; [0973] = 0xFFFF;
MOV [0973],FFFF ; }
05B0: CMP WORD PTR [092E],00 ; if (errcode == 0 || errcode == 2)
JE 05BE ; { write prot drv not ready
CMP WORD PTR [092E],02
JNE 05D0
05BE: MOV [0977],00 ; [0977] = 0;
CMP WORD PTR [0973],00 ; if ([0973] != 0)
JE 05D0 ; [0973] = 0xFFFF;
MOV [0973],FFFF ; }
; THE BIG RETURN TO DOS!!!!!
05D0: MOV AL,AH ; AL has return code (0,1,2)
MOV DX,DI
05D4: CALL 05EF ; Restore orginal file handle 0
POP DS
IRET ; Return to DOS
}
fat_bad()
{
05D9: MOV DX,0810 ; print "File allocation table bad"
CALL 0635
MOV DX,07A5 ; print "drive <d>"
CALL 0635
MOV AL,02
JMP 05D4 ; return to DOS with code 2
}
command_bad()
{
05E9: CALL 0608 ; command_missing();
JMP 03D6
}
; Save registers
05EF: PUSH DS
PUSH BX
PUSH AX
; Restore the original file handle 0
MOV AH,51
INT 21
MOV AX,[0930] ; PSP:[18H] = [930]
MOV DS,BX
MOV [0018],AX
; Restore registers
POP AX
POP BX
POP DS
RET
bad_command_interp()
{
0602: MOV DX,08BC ; print "Bad or missing command interpreter"
JMP 0302
}
interp_missing()
{
0608: MOV DX,082D
MOV AL,[0965]
CALL 0468 ; get disk info using int21(19) and int 11
JNE 0602
CALL 0635 ; print message "Insert CMD.COM disk in"
MOV DX,083D ; if ([0965] == 0)
CMP BYTE PTR [0965],00 ; print message "default drive"
JNE 0623 ; else
MOV DX,0845 ; print message "drive C"
0623: CALL 0635
MOV DX,0852 ; print message "And strike key when ready"
CALL 0635
MOV AX,0C07 ; get the user's keystroke
INT 21
RET
}
; ***************************************************************************
; * MESSAGE PRINTING ROUTINES
; ***************************************************************************
put_CR()
{
632: MOV DX,07AD ; put out a <CR>
print_message();
}
; This routine prints a (encoded) message to the terminal.
; If the message has a digit in it ('0'-'9'), then use the digit to index
; into an array of submessage pointers starting at 701.
print_message(dx)
{
635: PUSH AX
PUSH BX
PUSH DX
PUSH SI
MOV SI,DX
63B: LODSB
PUSH AX ; save the loaded char
AND AL,7F ; mask out high bits
CMP AL,30 ; is char between '0' and '9'?
JB 0658 ; NO - print the character
CMP AL,39
JA 0658
SUB AL,30 ; AL = c - '0'
CBW ; make digit take up entire AX reg
SHL AX,1 ; DX = submessage pointed to by 701[AX]
MOV BX,0701
ADD BX,AX
MOV DX,[BX]
CALL 0635 ; call routine recursively print sub-message
JMP 065E ; other digits
658: MOV DL,AL ; DL has the character to print
MOV AH,02 ; print the character
INT 21
; DOS turns on the high bit of the last char of the message in order to
; save on the terminating char ('\0' or '$'). If the high bit is not on,
; we continue to print the remaining chars of the message.
65E: POP AX ; get the original character
TEST AL,80 ; is the high bit on?
JE 063B ; NO! print more characters
; Restore the registers.
POP SI
POP DX
POP BX
POP AX
RET
} CALL 0635
MOV AX,0C07 ; get the user's keystroke
INT 21
RET
}
; **************